% function to calculate 
% start and end matrix indices for 
% fft etc
% this uses selblock (array of ones and zeros-selction)
% uses 750 flops on 100 stack array with overlap;
%latest date 04.11.2002

%#eml
function[SelArray,len] = GetSelArray(ProcDef);

SelArray = zeros([2*ProcDef.len-1,2]); % ignoring that when overlap is zero, the required array length is half
selblock = ProcDef.SelStacks;
ov = ProcDef.overlap;
block = ProcDef.block;
len=length(selblock);


if len <1,
   return;
end;

if ov ==1,
   len = 2*len-1;
   update=block/2;
   oblock=zeros([1 len]);
   oblock(1:2:len) = selblock;
      for i = 2:2:len,
      if oblock(i-1) == 1 && oblock(i+1)==1,
         oblock(i)= 1;
      else
         oblock(i)= 0;
      end;
   end;
   clear selblock;
selblock=oblock;  
else
   update=block;
end;

st = 1;
en = block;
p=0;
for i = 1:len,

   if selblock(i) == 1,
      p=p+1;
      SelArray(p,:) = [st en];
   end;
   
   st = st+update; 
   en = en+update;
end;
len=p;



      

 
   


